<?php

/**
 * Contains a class to display /owner/events.php.
 *
 * PHP Version 5
 *
 * @category BuyLocal
 * @package  BuyLocal
 * @author   Jeremy Walker <walkej18@gmail.com>
 * @author   Spencer Hakim <hakims@rpi.edu>
 * @license  http://opensource.org/licenses/gpl-license.php GNU Public License
 * @link     http://code.google.com/p/buylocalopensourcerensselaer/
 */
 
/** @uses valueOf For safe handling of arrays. */
require_once 'function_valueof.php';
 
/**
 * A class to display /owner/events.php.
 *
 * @category BuyLocal
 * @package  BuyLocal
 * @author   Jeremy Walker <walkej18@gmail.com>
 * @author   Spencer Hakim <hakims@rpi.edu>
 * @license  http://opensource.org/licenses/gpl-license.php GNU Public License
 * @link     http://code.google.com/p/buylocalopensourcerensselaer/
 */
class PageOwnerEvents extends Page
{
    /**
     * Constructor function.  Calls the parent constructor, sets the title,
     *
     */
    public function __construct()
    {
        parent::__construct();
        parent::setTitle("Owner: My Events");
    }
    
    /**
     * Function to print the list of stores matching the userid.
     *
     * @access private
     * @return null
     */
    private function _printEvents()
    {
        
        $events = $this->db->getEventsforOwner($this->user->id);
        $map    = new Map($events);
        echo ' <ul class="stores">', "\n";
        $countries = $this->db->getCountries();
        foreach ($events as $event) {
            $event->country = $countries[$event->country - 1]['name'];
            $event->printListItem(true);
        }
        echo ' </ul>', "\n",
             ' <h2>These Events on a Map</h2>', "\n";
        $map->display();
    }
    
    /**
     * Function to display the page.
     *
     * @access public
     * @return null
     */
    public function display()
    {
        parent::printHeader();
        $this->_printEvents();
        parent::printFooter();
    }
}

?>